layui.use(['form','layer','table','laytpl'],function(){
    var form = layui.form,
        layer = parent.layer === undefined ? layui.layer : top.layer,
        $ = layui.jquery,
        laytpl = layui.laytpl,
        table = layui.table;

    //角色列表
    var tableIns = table.render({
        elem: '#roleList',
        url : Feng.ctxPath+'/role/roleList',
        cellMinWidth : 95,
        page : true,
        height : "full-125",
        limits : [10,15,20,25],
        limit : 20,
        id : "roleListTable",
        cols : [[
            {type: "checkbox", fixed:"left", width:50},
            {field: 'id',title: 'ID', width:60, align:"center" },
            {field: 'roleName', title: '角色名称', minWidth:100, align:"center"},
            {field: 'pid', title: '上级角色', minWidth:100, align:"center"},
            {field: 'roleDesc', title: '角色描述', minWidth:100, align:"center"},
            {field: 'tips', title: '别名', minWidth:100, align:"center"}
        ]]
        /*,done: function () {
            $("[data-field='id']").css('display','none');
        }*/
    });

    //权限分配
    $(".assign").click(function(){
        var checkStatus = table.checkStatus("roleListTable");//选择状态{data: Array(0), isAll: false}  {data: Array(1), isAll: false}  //{account: "test", createtime: "", email: "test@qq.com", id: "2", isDeleted: "0", …}
        var data = checkStatus.data;//选择的数据
        //判断选中的状态和选中的数量
        if(data.length != 1){
            layer.msg("请选择一条角色!");
            return false;
        }
        var roleId = data[0].id;
        var index = layui.layer.open({
            title : "权限分配",
            type : 2,
            area: ['800px', '450px'] ,
            content : Feng.ctxPath+"/role/role_assign/"+roleId
        });

        $(window).on("resize",function(){
            layui.layer.full(index);
        });
    })


});
